package com.yisoo.rs.rsmovie.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import com.yisoo.rs.common.vo.MovieJsonVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 
 * 
 * @author mmciel
 * @email 761998179@qq.com
 * @date 2021-12-03 17:03:58
 */
@Data
@TableName("movies_type")
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class TypeEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * ID
	 */
	@TableId
	private Long typeId;
	/**
	 * 名字
	 */
	private String typeName;
	private Long appId;
    public static List<TypeEntity> generatorByMovieJsonVo(Long appId, List<MovieJsonVo> dataList) {
		HashSet<String> stars = new HashSet<>();
		for (MovieJsonVo m : dataList) {
			stars.addAll(new HashSet<>(m.getMvType()));
		}
		return stars.stream().map(temp -> new TypeEntity(null, temp, appId)).collect(Collectors.toList());
    }
}
